import { ListState } from "../types"
import { request } from "../utils/request"
export interface LoginState {
	username: string
	password: string
}

export function login(data: LoginState) {
	return request.post('/api/login', data)
}


export function getUserInfo(token: string) {
	return request.get('/api/user/info', { params: { token } })
}


export function getList(params?: { type?: string, desc?: string, searchValue?: string }) {
	return request.get('/api/list', { params })
}


export function deleteList(id: string) {
	return request.delete('/api/list/' + id)
}


export function postList(row: ListState) {
	return request.post('/api/list/' + row.id, row)
}


export function postListAdd(row: {
	title: string
	price: string
	type: string
	image: string
}) {
	return request.post('/api/list', row)
}